<?php

namespace App\Exports;

use App\Models\Dashboard;
use App\Models\Depart;
use App\Models\Service;
use Maatwebsite\Excel\Concerns\FromCollection;
use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\FromView;

class DashboardExport implements FromView
{
   	public function __construct($where)
    {
        $this->where = $where;
    }

    public function view(): View
    {   
        $where = $this->where;
        $query = Dashboard::query();
        if(array_get($where,'keyword')) {
            $query->where('customer_name','like','%'.$where['keyword'].'%')
                   ->orWhere('car_num','like','%'.$where['keyword'].'%');    
        }
        
    	$list = $query->get();
    	
        return view('admin.dashboard.export_index', compact('list'));
    }
}
